//实体类
use diesel::prelude::*;
use gset::Getset;

pub trait ConvertAble {}
#[derive(Queryable, Selectable, Default, Debug, serde::Serialize, serde::Deserialize, Clone)]
#[diesel(table_name=crate::schema::models)]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
pub struct Models {
    model_id: i32,
    model_name: String,
    description: Option<String>,
}

impl Models {
    pub fn new() -> Self {
        Models::default()
    }
}
#[derive(serde::Serialize, Debug, Default, Insertable)]
#[diesel(table_name=crate::schema::models)]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
pub struct NewModel<'a> {
    model_name: &'a str,
    description: &'a str,
}

#[derive(
    serde::Deserialize, Debug, Queryable, Selectable, Insertable, serde::Serialize, Default, Clone,
)]
#[diesel(table_name = crate::schema::users)]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
#[derive(Getset)]

pub struct User {
    #[getset(get, name = "get_id", vis = "pub")]
    #[getset(set_own, name = "id", vis = "pub")]
    #[getset(set, vis = "pub")]
    id: i32,
    #[getset(get, name = "get_username", vis = "pub")]
    #[getset(set_own, name = "username", vis = "pub")]
    #[getset(set, vis = "pub")]
    username: String,
    #[getset(get, name = "get_password", vis = "pub")]
    #[getset(set_own, name = "password", vis = "pub")]
    #[getset(set, vis = "pub")]
    password: String,
    #[getset(get, name = "get_last_predict", vis = "pub")]
    #[getset(set_own, name = "last_predict", vis = "pub")]
    #[getset(set, vis = "pub")]
    last_predict: Option<String>,
    #[getset(get, name = "get_last_result", vis = "pub")]
    #[getset(set_own, name = "last_result", vis = "pub")]
    #[getset(set, vis = "pub")]
    last_result: Option<String>,
}
impl User {
    pub fn new() -> Self {
        Self {
            id: i32::default(),
            username: String::default(),
            password: String::default(),
            last_predict: Option::default(),
            last_result: Option::default(),
        }
    }
}

impl ConvertAble for User {}
